<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>knet: 管道引用</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">knet
   &#160;<span id="projectnumber">1.4.3</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="modules.html"><span>模块</span></a></li>
      <li><a href="annotated.html"><span>类</span></a></li>
      <li><a href="files.html"><span>文件</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">函数</a>  </div>
  <div class="headertitle">
<div class="title">管道引用</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
函数</h2></td></tr>
<tr class="memitem:ga7b76c4078bbe8272206a5d7467ccd4ed"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#ga7b76c4078bbe8272206a5d7467ccd4ed">channel_ref_share</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:ga7b76c4078bbe8272206a5d7467ccd4ed"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab4248c6e10ac538b5d37b927bbe39ef1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#gab4248c6e10ac538b5d37b927bbe39ef1">channel_ref_leave</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:gab4248c6e10ac538b5d37b927bbe39ef1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1a8d1f5550cf26313cbb6575e8b2a32c"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#ga1a8d1f5550cf26313cbb6575e8b2a32c">channel_ref_connect</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref, const char *ip, int port, int timeout)</td></tr>
<tr class="separator:ga1a8d1f5550cf26313cbb6575e8b2a32c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae9ae0ae2a42eabf6a544ce4e0f001c9e"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#gae9ae0ae2a42eabf6a544ce4e0f001c9e">channel_ref_accept</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref, const char *ip, int port, int backlog)</td></tr>
<tr class="separator:gae9ae0ae2a42eabf6a544ce4e0f001c9e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae003fde214ddbf4feec22ddb89b8257c"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#gae003fde214ddbf4feec22ddb89b8257c">channel_ref_check_balance</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:gae003fde214ddbf4feec22ddb89b8257c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadddbdc58824b567334d46493decc90f8"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#gadddbdc58824b567334d46493decc90f8">channel_ref_check_state</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref, channel_state_e state)</td></tr>
<tr class="separator:gadddbdc58824b567334d46493decc90f8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga49d6ba5f0b9aad95ae5c5710dca392a1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#ga49d6ba5f0b9aad95ae5c5710dca392a1">channel_ref_close</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:ga49d6ba5f0b9aad95ae5c5710dca392a1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf0c977ef05b7e767a8ef166a8037ec8b"><td class="memItemLeft" align="right" valign="top">socket_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#gaf0c977ef05b7e767a8ef166a8037ec8b">channel_ref_get_socket_fd</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:gaf0c977ef05b7e767a8ef166a8037ec8b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf8d2758e1e063e04512049c9a9869d5e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__stream__t.html">stream_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#gaf8d2758e1e063e04512049c9a9869d5e">channel_ref_get_stream</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:gaf8d2758e1e063e04512049c9a9869d5e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad840fd786ca7092d528a8fc45c2e2a76"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__loop__t.html">loop_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#gad840fd786ca7092d528a8fc45c2e2a76">channel_ref_get_loop</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:gad840fd786ca7092d528a8fc45c2e2a76"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7627dbcdb87269ef2fae5bcbbb210720"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#ga7627dbcdb87269ef2fae5bcbbb210720">channel_ref_set_cb</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref, channel_ref_cb_t cb)</td></tr>
<tr class="separator:ga7627dbcdb87269ef2fae5bcbbb210720"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4e46196f7ac40bdd14a1407167e88b7b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#ga4e46196f7ac40bdd14a1407167e88b7b">channel_ref_set_timeout</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref, int timeout)</td></tr>
<tr class="separator:ga4e46196f7ac40bdd14a1407167e88b7b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7bcafd2461a1edfde9c581cb946dcd44"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__address__t.html">address_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#ga7bcafd2461a1edfde9c581cb946dcd44">channel_ref_get_peer_address</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:ga7bcafd2461a1edfde9c581cb946dcd44"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1dcf6af0c992fa21f9dcd03c8f763ec4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__address__t.html">address_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#ga1dcf6af0c992fa21f9dcd03c8f763ec4">channel_ref_get_local_address</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:ga1dcf6af0c992fa21f9dcd03c8f763ec4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3fd39b821fef38abd518db6240e79068"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#ga3fd39b821fef38abd518db6240e79068">channel_ref_get_uuid</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:ga3fd39b821fef38abd518db6240e79068"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad44fcb68845cb3ebb582a9de6db9abd0"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___xE7_xAE_xA1_xE9_x81_x93_xE5_xBC_x95_xE7_x94_xA8.html#gad44fcb68845cb3ebb582a9de6db9abd0">channel_ref_equal</a> (<a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *a, <a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *b)</td></tr>
<tr class="separator:gad44fcb68845cb3ebb582a9de6db9abd0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<p>管道引用</p>
<pre>
channel_ref_t作为channel_t的包装器，对于用户透明化了管道的内部实现，同时提供了引用计数用于
管道的生命周期管理.</pre><pre>管道有3种类型：
1. 连接器
2. 监听器
3. 由监听器接受的新管道</pre><pre>管道有3种状态:
1. 新建立 刚建立但不确定是作为连接器或者监听器存在
2. 活跃   已经确定了自己的角色
3. 关闭   已经关闭，但还未销毁，引用计数不为零</pre><pre>在没有负载均衡器存在的情况下(loop_t没有通过loop_balancer_attach关联到loop_balancer_t),
所有连接器管道都会在当前loop_t内运行，所有由监听器接受的管道也会在loop_t内运行.
如果loop_t已经关联到负载均衡器，这对连接器管道没有影响，但监听器接受的管道可能不在当前loop_t内
运行，负载均衡器会根据活跃管道的数量将这个管道分配到其他loop_t运行，或者仍然在当前loop_t内运行，
结果取决于当前所有loop_t负载的情况（活跃管道的数量）.
可以调用函数channel_ref_check_balance确定管道是否被负载均衡调配，调用channel_ref_check_state
检查管道当前所处的状态，channel_ref_close关闭管道，无论此时管道的引用计数是否为零，管道的套接字都会
被关闭，当管道引用计数为零时，loop_t才会真正销毁它.调用channel_ref_equal可以判断两个管道引用是否
指向同一个管道.</pre><pre>可以通过调用channel_ref_set_timeout设置管道的读空闲超时（秒），这可以用做心跳包的处理，调用
channel_ref_connect时最后一个参数传递一个非零值可以设置连接器的连接超时（秒），这可以用于重连.
调用channel_ref_get_socket_fd得到管道套接字，调用channel_ref_get_uuid的到管道UUID.
</pre> <h2 class="groupheader">函数说明</h2>
<a class="anchor" id="gae9ae0ae2a42eabf6a544ce4e0f001c9e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int channel_ref_accept </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>ip</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>port</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>backlog</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>将管道转换为监听管道</p>
<p>由这个监听管道接受的新连接将使用与监听管道相同的发送缓冲区最大数量限制和接受缓冲区长度限制, channel_ref_accept所接受的新连接将被负载均衡，实际运行在哪个loop_t内依赖于实际运行的情况 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
    <tr><td class="paramname">ip</td><td>IP </td></tr>
    <tr><td class="paramname">port</td><td>端口 </td></tr>
    <tr><td class="paramname">backlog</td><td>等待队列上限（listen()) </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname">error_ok</td><td>成功 </td></tr>
    <tr><td class="paramname">其他</td><td>失败 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gae003fde214ddbf4feec22ddb89b8257c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int channel_ref_check_balance </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>检测管道是否是通过负载均衡关联到当前的loop_t </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname">0</td><td>不是 </td></tr>
    <tr><td class="paramname">非0</td><td>是 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gadddbdc58824b567334d46493decc90f8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int channel_ref_check_state </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">channel_state_e&#160;</td>
          <td class="paramname"><em>state</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>检测管道当前状态 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
    <tr><td class="paramname">state</td><td>需要测试的状态 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname">1</td><td>是 </td></tr>
    <tr><td class="paramname">0</td><td>不是 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga49d6ba5f0b9aad95ae5c5710dca392a1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void channel_ref_close </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>关闭管道 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga1a8d1f5550cf26313cbb6575e8b2a32c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int channel_ref_connect </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>ip</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>port</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>timeout</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>主动连接</p>
<p>调用channel_ref_connect的管道不会被负载均衡，将在当前loop_t所运行的线程运行 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
    <tr><td class="paramname">ip</td><td>IP </td></tr>
    <tr><td class="paramname">port</td><td>端口 </td></tr>
    <tr><td class="paramname">timeout</td><td>连接超时（秒） </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname">error_ok</td><td>成功 </td></tr>
    <tr><td class="paramname">其他</td><td>失败 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gad44fcb68845cb3ebb582a9de6db9abd0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int channel_ref_equal </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>测试两个管道引用是否指向同一个管道 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">a</td><td>channel_t实例 </td></tr>
    <tr><td class="paramname">b</td><td>channel_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname">0</td><td>不同 </td></tr>
    <tr><td class="paramname">非零</td><td>相同 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga1dcf6af0c992fa21f9dcd03c8f763ec4"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct__address__t.html">address_t</a>* channel_ref_get_local_address </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>取得本地地址 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>address_t实例 </dd></dl>

</div>
</div>
<a class="anchor" id="gad840fd786ca7092d528a8fc45c2e2a76"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct__loop__t.html">loop_t</a>* channel_ref_get_loop </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>取得管道所关联的事件循环 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>loop_t实例 </dd></dl>

</div>
</div>
<a class="anchor" id="ga7bcafd2461a1edfde9c581cb946dcd44"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct__address__t.html">address_t</a>* channel_ref_get_peer_address </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>取得对端地址 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>address_t实例 </dd></dl>

</div>
</div>
<a class="anchor" id="gaf0c977ef05b7e767a8ef166a8037ec8b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">socket_t channel_ref_get_socket_fd </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>取得管道套接字 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>套接字 </dd></dl>

</div>
</div>
<a class="anchor" id="gaf8d2758e1e063e04512049c9a9869d5e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct__stream__t.html">stream_t</a>* channel_ref_get_stream </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>取得管道数据流 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>stream_t实例 </dd></dl>

</div>
</div>
<a class="anchor" id="ga3fd39b821fef38abd518db6240e79068"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t channel_ref_get_uuid </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>获取管道UUID </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>管道UUID </dd></dl>

</div>
</div>
<a class="anchor" id="gab4248c6e10ac538b5d37b927bbe39ef1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void channel_ref_leave </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>减少管道引用计数，并销毁channel_ref_t实例 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga7627dbcdb87269ef2fae5bcbbb210720"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void channel_ref_set_cb </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">channel_ref_cb_t&#160;</td>
          <td class="paramname"><em>cb</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>设置管道事件回调</p>
<p>事件回调将在关联的loop_t实例所在线程内被回调 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
    <tr><td class="paramname">cb</td><td>回调函数 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga4e46196f7ac40bdd14a1407167e88b7b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void channel_ref_set_timeout </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>timeout</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>设置管道空闲超时</p>
<p>管道空闲超时依赖读操作作为判断，在timeout间隔内未有可读数据既触发超时 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
    <tr><td class="paramname">timeout</td><td>超时（秒） </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga7b76c4078bbe8272206a5d7467ccd4ed"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a>* channel_ref_share </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>增加管道引用计数，并创建与管道关联的新的channel_ref_t实例</p>
<p>channel_ref_share调用完成后，可以在当前线程内访问其他线程(loop_t)内运行的管道 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>channel_ref_t实例 </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
生成于 2015年 七月 9日 星期四 14:59:53 , 为 knet使用  &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>
